﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>05_五彩的光源</title>
    <script src="../js/three.js"></script>
</head>
<body>
    <script>
        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000); // 透视投影相机
        var renderer = new THREE.WebGLRenderer({
            antialias: true
        });
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        //var light = new THREE.AmbientLight(0xff0000); // 环境光
        //var light = new THREE.PointLight(0xff0000); // 点光源
        var light = new THREE.SpotLight(0xff0000, 1, 0, 30); // 聚光灯
        //var light = new THREE.DirectionalLight(0xffffff); // 平行光
        light.position.set(10, 10, 10);
        scene.add(light);

        var geometry = new THREE.CylinderGeometry(5, 10, 20);
        var material = new THREE.MeshLambertMaterial({ color: 0xcccccc }); // 兰伯特材质
        var cylinder = new THREE.Mesh(geometry, material);
        scene.add(cylinder);
        cylinder.position.set(-10, -20, 0);
        cylinder.rotation.set(0.3, 0, 0);

        camera.position.set(0, 0, 100);
        camera.lookAt(0, 0, 0);

        renderer.render(scene, camera);
    </script>
</body>
</html>
